<template>
  <van-field :label="this.labelName" readonly :border="true">
    <template #input>
      <div style="display: flex; flex-direction: column">
        <div
          style="margin-top: 0px; border-radius: 0px; display: flex"
          v-for="(item, index) in fileList"
          :key="index"
        >
          <img
            style="
              margin-right: 10px;
              vertical-align: middle;
              height: 18px;
              width: 18px;
            "
            v-bind:src="srcValue2(item.AttExt)"
            alt=""
          />
          <div
            style="color: #1989fa; flex: 1"
            @click.stop="goFile(item.AttCode)"
          >
            {{ item.AttName + item.AttExt }}
          </div>
        </div>
      </div>
    </template>
  </van-field>
</template>

<script>
// 文件描述：   根据文件结尾判断应该显示什么图片（还可以进一步优化，并没有达到最优）
//更改时间：
//更改人：高先生
import srcValue from "@/utils/srcValue.js";
export default {
  props: {
    labelName: {
      type: String,
      required: false,
    },
    attachs: {},
    fileLists: [],
  },
  data() {
    return {
      baseUrl: process.env.VUE_APP_BASE_API,
      isfileListsArry: [],
      filePopup: false,
      showPdf: false,
      pdfAttcode: "",
      pdfUrl: "",
      showImg: false,
      imagePath: "",
      edit: true,
      require: false,
    };
  },
  computed: {
    fileList: {
      get() {
        if (this.fileLists) {
          return this.fileLists;
        }
        if (this.attachs) {
          return JSON.parse(this.attachs);
        }
        return [];
      },
    },
  },
  methods: {
    srcValue2(AttExt) {
      return srcValue(AttExt);
    },
    goFile(attachCode) {
      this.$router.push("/Attach/AatachDetail?attCode=" + attachCode);
    },
  },
};
</script>
<style lang="less">
.file-format::after {
  content: "";
  display: block;
  position: absolute;
  left: 10px;
  right: 10px;
  border-bottom: 0.02667rem solid #ebedf0;
}
</style>
